// $codepro.audit.disable
/*
 * UserController.java
 */
package edu.gatech.oad.user;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Date;

public class UserController {
	private User user;
	
	/**
	 * Creates a new UserController to edit the passed-in User object.
	 * @param user The User object to edit. 
	 */
	
	public UserController(User user) {
		this.user = user;
	}
	
	/**
	 * Creates a new UserController along with a new User object of the desired class.
	 * @param userClass The class of user to create.
	 */
	public UserController(Class<? extends User> userClass, String username) {
		try {
			Constructor<? extends User> constructor = userClass.getConstructor(String.class);
			this.user = constructor.newInstance(username);
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public User getUser() {
		return this.user;
	}
	
	public void setUser(User user) {
		this.user = user;
	}
	
	public void setUserFirstName(String firstName) {
		this.user.setFirstName(firstName);
	}
	
	public void setUserLastName(String lastName) {
		this.user.setLastName(lastName);
	}
	
	public void setUserEmailAddress(String emailAddress) {
		this.user.setEmailAddress(emailAddress);
	}
	
	public void setUserPhoneNumber(String phoneNumber) {
		this.user.setPhoneNumber(phoneNumber);
	}
	
	public void setUserGender(String gender) {
		//TODO fixme
	}
	
	public void setUserBirthday(Date birthday) {
		this.user.setBirthday(birthday);
	}
	
	public String toString() {
		return "UserController editing " + user.toString();
	}
}
